package com.dora.kafka.controller;

import com.dora.kafka.messaging.KafkaProducer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 卡夫卡控制器
 *
 * @author Clarence
 * @date 2024/03/03
 */
@RestController
public class KafkaController {

    @Autowired
    private KafkaProducer kafkaProducer;

    /**
     * 发送值消息
     */
    @GetMapping("/sendMessageWithValue")
    public void sendMessageWithValue(){
        kafkaProducer.sendMessageWithValue("------------测试消息-----------");
    }

    /**
     * 发送键值消息
     */
    @GetMapping("/sendMessageWithKeyValue")
    public void sendMessageWithKeyValue(){
        kafkaProducer.sendMessageWithKeyValue("测试键","------------测试消息-----------");
    }

    /**
     * 发送回调消息
     */
    @GetMapping("/sendCallbackMessage")
    public void sendCallbackMessage(){
        kafkaProducer.sendCallbackMessage("------------测试消息-----------");
    }
}
